package com.wisecoach.gatewayplus.transaction.seata;

import com.wisecoach.gatewayplus.transaction.*;
import io.seata.core.context.RootContext;

/**
 * {@code @author:} wisecoach
 * {@code @date:} 2023/9/30 下午3:57
 * {@code @version:} 1.0.0
 */


public class SeataTransactionContextProvider extends AbstractTransactionContextProvider {

    @Override
    protected TransactionStatus getTransaction(TransactionAttribute attribute) {
        TransactionContext oldTransaction = TransactionContextHolder.getContext();
        boolean isNewTransaction = oldTransaction != null;
        String id = RootContext.getXID();
        return new DefaultTransactionStatus(id, attribute.getTransactionStrategy(), isNewTransaction);
    }
}
